package com.huaxia.service.deptLevels;

import com.huaxia.dao.deptLevels.*;
import com.huaxia.pojo.deptLevels.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.List;

/**
 * @author wangli 爱我华夏，爱我中华！
 * @date 2020/08/04 9:21
 */
@Service
public class DeptLevelsService {

    @Autowired
    private DeptBMMapper deptBMMapper;
    @Autowired
    private DeptBCMapper deptBCMapper;
    @Autowired
    private DeptASMapper deptASMapper;

    @Autowired
    private BranchStandardMapper branchStandardMapper;
    @Autowired
    private SaleDeptStandardMapper saleDeptStandardMapper;


    public List<DeptAS> getDeptAS() {

        return deptASMapper.getDeptAS();
    }

    public List<DeptBM> getDeptBM() {

        return deptBMMapper.getDeptBM();
    }

    public List<DeptBC> getDeptBC() {

        return deptBCMapper.getDeptBC();
    }

    public List<BranchStandard> getBranchStandard() {

        int month = getMonth();

        if (month % 3 == 0) {
            return branchStandardMapper.getBranchThi();
        } else if (month % 3 == 1) {
            return branchStandardMapper.getBranchFir();
        } else {
            return branchStandardMapper.getBranchSec();
        }
    }

    public List<SaleDeptStandard> getSaleDeptStandard() {

        int month = getMonth();

        if(month%3==0){
            return saleDeptStandardMapper.getSaleDeptThi();
        }else if(month%3==1){
            return saleDeptStandardMapper.getSaleDeptFir();
        }else{
            return saleDeptStandardMapper.getSaleDeptSec();
        }
    }

    public int getMonth() {
        Calendar cale = Calendar.getInstance();
        int month = cale.get(Calendar.MONTH) + 1;
        return month;
    }
}
